#include <iostream>

using namespace std;

class Line{
public:
    Line(int x1,int y1,int x2,int y2)
    :_impl(new LineImpl(x1,y1,x2,y2))
    {
        cout << "Line(int,int,int,int)" << endl;
    }

    ~Line(){
        if(_impl){
            delete _impl;
            _impl=nullptr;
        }
    }

    void printLine(){
        _impl->printLine();
    }

private:
    class LineImpl{
    public:
        LineImpl(int x1,int y1,int x2,int y2)
        :_pt1(x1,y1)
        ,_pt2(x2,y2)
        {
            cout << "LineImpl(int,int,int,int)" << endl;
        }

        void printLine(){
            _pt1.print();
            cout << "------->";
            _pt2.print();
            cout << endl;
        }

        class Point{
        public:
            Point(int x,int y)
            :_x(x)
            ,_y(y)
            {}

            void print(){
                cout << "(" << _x << "," << _y << ")" << endl;
            }

        private:
            int _x;
            int _y;
        };

    private:
        Point _pt1;
        Point _pt2;
    };

    LineImpl *_impl;
};

void test(){
    Line line(1,2,3,4);
    line.printLine();
}

int main()
{
    test();
    return 0;
}

